{include file="public/head" /}
<style>.admin-main{padding-top:0}</style>
</head>
<body>
<div class="am-cf admin-main">
    <!-- content start -->
    <div class="admin-content">
        <div class="admin-content-body">
            <div class="am-cf am-padding">
                <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">课程信息</strong></div>

            </div>

            <div class="am-u-md-12">
                <div class="am-btn-toolbar">
                    <div class="am-u-sm-12 am-u-md-4" style="float: right">
                        <form method="post" action="/admin/Course/index">
                            <div class="am-form-group">
                                <input type="text" name="keyword" value="{:input('request.keyword')}">
                                <button type="submit" class="am-btn am-btn-default am-btn-xs">搜索</button>
                                <a href="/admin/Course/index" class="am-btn am-btn-default am-btn-xs">重置</a>
                            </div>
                        </form>
                    </div>
                </div>

                <table class="am-table am-table-bd am-table-striped admin-content-table">
                    <thead>
                    <tr>
                        <th>课程编号</th>
                        <th>课程名称</th>
                        <th>开课教师</th>
                        <th>课程类别</th>
                        <th>上课日</th>
                        <th>上课地点</th>
                        <th>上课时间</th>
                        <th>限选人数</th>
                        <th>已选人数</th>
                        <th>创建时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {volist name="rows" id="vo"}
                    <tr>
                        <td>{$vo.id}</td>
                        <td>{$vo.name}</td>
                        <td>{$vo.teacher}</td>
                        <td>{$vo.type}</td>
                        <td>星期{$vo.day}</td>
                        <td>{$vo.classroom}</td>
                        <td>第{$vo.begin_lesson}-{$vo.end_lesson}节课</td>
                        <td>{$vo.limit_student_count}</td>
                        <td>{$vo.real_student_count}</td>
                        <td>{$vo.create_time}</td>
                        <td>
                            <div class="am-btn-toolbar">
                                <div class="am-btn-group am-btn-group-xs">
                                    <button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="showJoinList({$vo.id})"><span class="am-icon-list"></span> 查看已选学生列表</button>
                                </div>
                            </div>
                        </td>
                    </tr>
                    {/volist}
                    </tbody>
                </table>
                <span>共{$rows->total()}条记录</span>
                <div class="pagination" style="float: right">{$page}</div>
            </div>
        </div>
    </div>
</div>
<!--添加用户模态框-->
<div class="am-popup" id="Modal">
    <div class="am-popup-inner">
        <div class="am-popup-hd">
            <h4 class="am-popup-title">已选学生列表</h4>
            <span data-am-modal-close class="am-close">&times;</span>
        </div>
        <div class="am-popup-bd">
            <table class="am-table am-table-bd am-table-striped admin-content-table" id="joinList">
                <thead>
                <tr>
                    <th>学生编号</th>
                    <th>姓名</th>
                    <th>性别</th>
                    <th>手机</th>
                    <th>专业班级</th>
                    <th>选课时间</th>
                </tr>
                </thead>
                <tbody>
                </tbody>
            </table>
        </div>
    </div>
</div>
</div>
<script src="__STATIC__/js/ajax_form.js"></script>
<script>
    function showJoinList(id) {
        if(id == ''){
            layer.msg('参数获取失败,请刷新重试', {time: 1500, icon: 5});
            return false;
        }
        var table = $("#joinList");
        var tbody = table.find("tbody");
        tbody.find("tr").remove();
        $.post("{:url('admin/Course/getJoinList')}", {id: id}, function (res) {
            if(res.code==0){
                table.append("<p style='text-align: center'>无已选学生</p>");
            }else{
                var data = res.data.list;
                //根据记录条数来创建所需的表格行
                for(var i=0;i<data.length;i++){
                    tbody.append("<tr></tr>");
                    var tr = tbody.find("tr").eq(i);
                    //为每一行创建所需的6列td
                    for(var j=0;j<6;j++){
                        tr.append("<td></td>");

                    }
                    //表格赋值
                    var sex = data[i].sex==1 ? '男' : '女';
                    tr.find('td').eq("0").text(data[i].id);
                    tr.find('td').eq("1").text(data[i].name);
                    tr.find('td').eq("2").text(sex);
                    tr.find('td').eq("3").text(data[i].mobile);
                    tr.find('td').eq("4").text(data[i].major+'-'+data[i].class);
                    tr.find('td').eq("5").text(data[i].create_time);
                }
            }
        });
        $('#Modal').modal();
    }
</script>
</body>
</html>
